package com.bw.broker.controller;

import com.bw.broker.service.TbHouseBrokerService;
import com.bw.po.TbHouseBroker;
import com.bw.result.ResultVo;
import com.bw.vo.BrokerHouseNumVo;
import com.bw.vo.IdVo;
import com.bw.vo.LoginVo;
import com.bw.vo.TbHouseBrokerVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Set;

/**
 * @author liuzhihao
 * @version 1.0
 * @description: TODO
 * @date 2023/11/10 21:02:36
 */
@RestController
@Slf4j
@RequestMapping("/broker")
@Api(tags = "经纪人后台管理")
public class TbHouseBrokerController {

    @Autowired
    private TbHouseBrokerService tbHouseBrokerService;
    /** @Author 曹承坤
     * @Description //TODO 新增经纪人
     * @Date 09:02 23/11/11
     * @Param
     * @param tbHouseBrokerVo
     * @return
     * @return com.bw.result.ResultVo
     **/
    @PostMapping("/add")
    @ApiOperation("经纪人新增")
    public ResultVo add(@RequestBody TbHouseBrokerVo tbHouseBrokerVo){
        return tbHouseBrokerService.add(tbHouseBrokerVo);
    }
    /** @Author 曹承坤
     * @Description //TODO 经纪人登录
     * @Date 11:16 23/11/13
     * @Param
     * @param loginVo
     * @return
     * @return com.bw.result.ResultVo
     **/
    @PostMapping("/BrokerLogin")
    @ApiOperation("经纪人登录")
    public ResultVo login(@RequestBody LoginVo loginVo){
        return tbHouseBrokerService.login(loginVo);
    }
    /** @Author 曹承坤
     * @Description //TODO 发送短信
     * @Date 11:16 23/11/13
     * @Param
     * @param loginVo
     * @return
     * @return com.bw.result.ResultVo
     **/
    @PostMapping("/sendCode")
    @ApiOperation("发送短信")
    public ResultVo sendCode(@RequestBody LoginVo loginVo){
        return tbHouseBrokerService.sendCode(loginVo);
    }
    /** @Author 曹承坤
     * @Description //TODO 修改经纪人
     * @Date 09:02 23/11/11
     * @Param
     * @param tbHouseBrokerVo
     * @return
     * @return com.bw.result.ResultVo
     **/
    @PostMapping("/update")
    @ApiOperation("修改经纪人")
    public ResultVo update(@RequestBody TbHouseBrokerVo tbHouseBrokerVo){
        return tbHouseBrokerService.update(tbHouseBrokerVo);
    }
    /** @Author 曹承坤
     * @Description //TODO 删除经纪人
     * @Date 09:02 23/11/11
     * @Param
     * @param tbHouseBrokerVo
     * @return
     * @return com.bw.result.ResultVo
     **/
    @PostMapping("/deleteHouse")
    @ApiOperation("删除经纪人")
    public ResultVo deleted(@RequestBody TbHouseBrokerVo tbHouseBrokerVo){
        return tbHouseBrokerService.deleted(tbHouseBrokerVo);
    }
    /** @Author 曹承坤
     * @Description //TODO 经纪人列表
     * @Date 09:02 23/11/11
     * @Param
     * @param tbHouseBrokerVo
     * @return
     * @return com.bw.result.ResultVo
     **/
    @PostMapping("/list")
    @ApiOperation("经纪人列表")
    public ResultVo list(@RequestBody TbHouseBrokerVo tbHouseBrokerVo){
        return tbHouseBrokerService.list(tbHouseBrokerVo);
    }
    /** @Author 曹承坤
     * @Description //TODO 查看经纪人
     * @Date 09:02 23/11/11
     * @Param
     * @param idVo
     * @return
     * @return com.bw.result.ResultVo
     **/
    @PostMapping("/getById")
    @ApiOperation("通过经纪人id查看经纪人")
    public TbHouseBrokerVo getById(@RequestBody IdVo idVo){
        return tbHouseBrokerService.ById(idVo);
    }
    /** @Author 曹承坤
     * @Description //TODO 通过经纪人名字查看经纪人
     * @Date 09:02 23/11/11
     * @Param
     * @param brokerName
     * @return
     * @return com.bw.result.ResultVo
     **/
    @PostMapping("/getByName")
    @ApiOperation("通过经纪人名字查看经纪人")
    public ResultVo getByName(@RequestParam("brokerName") String brokerName){
        return tbHouseBrokerService.getByName(brokerName);
    }
    /** @Author 曹承坤
     * @Description //TODO 通过县区id查看经纪人
     * @Date 09:02 23/11/11
     * @Param
     * @param CountyId
     * @return
     * @return com.bw.result.ResultVo
     **/
    @PostMapping("/getByCountyId")
    @ApiOperation("通过县区id查看经纪人")
    public Set getByCountyId(@RequestParam("CountyId") Integer CountyId){
        return tbHouseBrokerService.getByCountyId(CountyId);
    }

    @PostMapping("/subtractBrokerHouse")
    @ApiOperation("经纪人房屋数量减一")
    public int subtractBrokerHouse(@RequestBody BrokerHouseNumVo brokerHouseNumVo){
        return  tbHouseBrokerService.subtractBrokerHouse(brokerHouseNumVo);
    };
    @PostMapping("/appendBrokerHouse")
    @ApiOperation("经纪人房屋数量加一")
    public int appendBrokerHouse(@RequestBody BrokerHouseNumVo brokerHouseNumVo){
        return  tbHouseBrokerService.appendBrokerHouse(brokerHouseNumVo);
    };
    @PostMapping("/corporationList")
    @ApiOperation("公司列表")
    public ResultVo corporationList(){
        return  tbHouseBrokerService.corporationList();
    };

}
